/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Janela.java
 *
 * Created on 30/10/2009, 09:11:56
 */

package interfaceGrafica;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import logica.grafo.Aresta;
import logica.grafo.Dijkstra;
import logica.grafo.Grafo;
import org.jgraph.JGraph;
import org.jgraph.graph.DefaultEdge;
import org.jgraph.graph.GraphConstants;

/**
 *
 * @author Thiago
 */
public class Janela extends javax.swing.JFrame {

    /** Creates new form Janela */
    public Janela() {
        initComponents();
        //DEIXA A TELA MAXIMIZADA.
        Toolkit tk=Toolkit.getDefaultToolkit();
        Dimension d=tk.getScreenSize();
        this.setSize(d);
        //DIZ QUE A JANELA NÃO PODE SER REDIMENSIONADA.
        this.setResizable(false);
        jDialog1.setSize(500, 200);
        jDialog1.setResizable(false);
        jDialog1.setLocationRelativeTo(this);
        jDialog1.setVisible(false);
        jDialog2.setSize(500, 200);
        jDialog2.setResizable(false);
        jDialog2.setLocationRelativeTo(this);
        jDialog2.setVisible(false);
        grafoTransporte = new JGraph();
        listaGrafoRedeDengue = new ArrayList<Grafo>();
        grafoDengue = new ArrayList<JGraph>();
        grafoDengueTransp = new ArrayList<JGraph>();
        grafoTranspDengue = new JGraph();
        numeroSemana = null;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDialog1 = new javax.swing.JDialog();
        jButton1 = new javax.swing.JButton();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        jDialog2 = new javax.swing.JDialog();
        jButtonVisualizar = new javax.swing.JButton();
        jComboBox2 = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jButton3 = new javax.swing.JButton();
        painelGrafo = new javax.swing.JDesktopPane();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem6 = new javax.swing.JMenuItem();

        jButton1.setText("Vizualizar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52" }));

        jLabel1.setText("Escolha a semana de vizualização da rede da dengue (1 - 52)");

        javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
        jDialog1.getContentPane().setLayout(jDialog1Layout);
        jDialog1Layout.setHorizontalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 321, Short.MAX_VALUE)
            .addGroup(jDialog1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1))
                .addContainerGap(18, Short.MAX_VALUE))
        );
        jDialog1Layout.setVerticalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 91, Short.MAX_VALUE)
            .addGroup(jDialog1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButtonVisualizar.setText("Visualizar");
        jButtonVisualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonVisualizarActionPerformed(evt);
            }
        });

        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52" }));

        jLabel2.setText("Escolha a semana de vizualização da rede Transporte x Dengue (1 - 52)");

        jButton3.setText("Gerar TXT");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jDialog2Layout = new javax.swing.GroupLayout(jDialog2.getContentPane());
        jDialog2.getContentPane().setLayout(jDialog2Layout);
        jDialog2Layout.setHorizontalGroup(
            jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 364, Short.MAX_VALUE)
            .addGroup(jDialog2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jDialog2Layout.createSequentialGroup()
                        .addComponent(jButtonVisualizar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton3)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jDialog2Layout.setVerticalGroup(
            jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 91, Short.MAX_VALUE)
            .addGroup(jDialog2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonVisualizar)
                    .addComponent(jButton3))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jMenu1.setText("Opções");

        jMenuItem1.setText("Abrir TXT");
        jMenu1.add(jMenuItem1);

        jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK));
        jMenuItem2.setText("Sair");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Vizualizar");

        jMenuItem3.setText("Rede Transporte");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem3);

        jMenuItem4.setText("Rede Epidemiologica");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem4);

        jMenuItem5.setText("Transp x Dengue");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem5);

        jMenuBar1.add(jMenu2);

        jMenu3.setText("Sobre");

        jMenuItem6.setText("Autores");
        jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem6ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem6);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(painelGrafo, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(painelGrafo, javax.swing.GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        dispose();
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        this.desenhaGrafoTransporte();        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        jDialog1.setVisible(true);
        jDialog1.setFocusable(true);
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        numeroSemana = jComboBox1.getSelectedIndex();
        this.desenhaGrafoDengue(numeroSemana);
        jDialog1.setVisible(false);
}//GEN-LAST:event_jButton1ActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        jDialog2.setVisible(true);
        jDialog2.setFocusable(true);
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void jButtonVisualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonVisualizarActionPerformed
        try {
            numeroSemana = jComboBox2.getSelectedIndex();
            this.geraTXTDengueXTransp(numeroSemana, true);
            //this.desenhaGrafoDijkstra(numeroSemana);
            jDialog2.setVisible(false);
        } catch (IOException ex) {
            Logger.getLogger(Janela.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButtonVisualizarActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        try {
            numeroSemana = jComboBox2.getSelectedIndex() + 1;
            this.geraTXTDengueXTransp(numeroSemana, false);
            //this.desenhaGrafoDijkstra(numeroSemana);
            jDialog2.setVisible(false);
        } catch (IOException ex) {
            Logger.getLogger(Janela.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
        JOptionPane.showMessageDialog(rootPane, "AUTORES:" +
                                                "\nANDRÉ BENEVIDES RODRIGUES" +
                                                "\nPAULO VICTOR C. DO N. SANTANA" +
                                                "\nSALOMÃO DE FREITAS" +
                                                "\nTHIAGO DO CARMO LIMA", "Autores do sistema", 1);
    }//GEN-LAST:event_jMenuItem6ActionPerformed

    public void setGrafoTransporte(JGraph graph){
        this.grafoTransporte = graph;
    }

    public void setGrafoDengue(ArrayList<JGraph> grafoDengue) {
        this.grafoDengue = grafoDengue;
    }

    public ArrayList<JGraph> getGrafoDengueTransp() {
        return grafoDengueTransp;
    }

    public void setGrafoDengueTransp(ArrayList<JGraph> grafoDengueTransp) {
        this.grafoDengueTransp = grafoDengueTransp;
    }

    public int getNumeroCidades() {
        return numeroCidades;
    }

    public void setNumeroCidades(int numeroCidades) {
        this.numeroCidades = numeroCidades;
    }

    public int getNumeroArestasRedeTransporte() {
        return numeroArestasRedeTransporte;
    }

    public void setNumeroArestasRedeTransporte(int numeroArestasRedeTransporte) {
        this.numeroArestasRedeTransporte = numeroArestasRedeTransporte;
    }

    public Grafo getGrafoRedeTransporte() {
        return grafoRedeTransporte;
    }

    public void setGrafoRedeTransporte(Grafo grafoRedeTransporte) {
        this.grafoRedeTransporte = grafoRedeTransporte;
    }

    public ArrayList<Grafo> getListaGrafoTranspXDengue() {
        return listaGrafoTranspXDengue;
    }

    public void setListaGrafoTranspXDengue(ArrayList<Grafo> listaGrafoTranspXDengue) {
        this.listaGrafoTranspXDengue = listaGrafoTranspXDengue;
    }

    public void setGrafoTranspDengue(JGraph grafoTranspDengue) {
        this.grafoTranspDengue = grafoTranspDengue;
    }

    public void setListaGrafoRedeDengue(ArrayList<Grafo> listaGrafoRedeDengue) {
        this.listaGrafoRedeDengue = listaGrafoRedeDengue;
    }

    public void pintaArestasDengue(int semana) {
        for (int w = 0; w < listaGrafoRedeDengue.get(semana).getArestas().size(); w++) {
            //System.out.println("Origem = [" + listaGrafoRedeDengue.get(semana).getArestas().get(w).getOrigem() + "] e Destino = [" + listaGrafoRedeDengue.get(semana).getArestas().get(w).getDestino() + "]");
            grafoDengue.get(semana).getGraphLayoutCache().insert(listaGrafoRedeDengue.get(semana).getArestas().get(w).getCell());
        }
    }

    public void pintaVerticesDengue(int semana) {
        // Insert the cells via the cache, so they get selected
        for (int z = 0; z < listaGrafoRedeDengue.get(semana).getVertices().size(); z++) {
            grafoDengue.get(semana).getGraphLayoutCache().insert(listaGrafoRedeDengue.get(semana).getVertices().get(z).getCell());
        }
    }

    public void geraTXTDengueXTransp(int semana, boolean visualizacao) throws IOException{

            String nomeArquivo = "Semana " + semana + ".txt";
        FileWriter x = new FileWriter(nomeArquivo, false);
        String conteudo = new String();

        for (int z = 0; z < listaGrafoRedeDengue.get(semana).getArestas().size(); z++) {
            ArrayList<Integer> shortestPaths = new ArrayList<Integer>();
            Dijkstra dijkstra = new Dijkstra();
            this.IniciaMatrizDeDistancia();
            d = new float[numeroCidades + 1];

            this.PreencheMatrizDeDistancia();
            int origem = listaGrafoRedeDengue.get(semana).getArestas().get(z).getOrigem();
            System.out.println("Origem:" + origem);
            int destino = listaGrafoRedeDengue.get(semana).getArestas().get(z).getDestino();
            System.out.println("Destino:" + destino);
            //System.out.println("Passou aki 1");
            shortestPaths = dijkstra.shortestPath(origem, destino, d, dist, numeroCidades);
            //System.out.println("Passou aki 2");
            System.out.println(shortestPaths);


            if (visualizacao) {
                System.out.println("Pintando caminho " + (z+1) + "/" + listaGrafoRedeDengue.get(semana).getArestas().size() +
                        " partindo de " + origem + " a " + destino);
                geraArestasDengueTransp(semana, shortestPaths);
                desenhaGrafoDijkstra(semana);
            } else {
                for (int i = 1; i < shortestPaths.size() - 1; i++) {
                    conteudo = shortestPaths.get(i) + " " + shortestPaths.get(i + 1); // criando nova linha e recuo no arquivo
                    x.write(conteudo + System.getProperty("line.separator"));
                    conteudo = shortestPaths.get(i+1) + " " + shortestPaths.get(i);
                    x.write(conteudo + System.getProperty("line.separator")); // armazena o texto no objeto x, que aponta para o arquivo
                    System.out.println("IMPRIME NO TXT? '" + shortestPaths.get(i) + " " + shortestPaths.get(i + 1) + "'");
                }
            }
        }
        x.close(); // cria o arquivo
    }

    public void geraArestasDengueTransp(int semana, ArrayList<Integer> shortestPaths) {
        for (int i = 1; i < shortestPaths.size()-1; i++) {
            DefaultEdge edge = new DefaultEdge();
            // Fetch the ports from the new vertices, and connect them with the edge
            edge.setSource(listaGrafoTranspXDengue.get(semana).getVertices().get(shortestPaths.get(i) - 1).getCell().getChildAt(0));
            edge.setTarget(listaGrafoTranspXDengue.get(semana).getVertices().get(shortestPaths.get(i+1) - 1).getCell().getChildAt(0));
            //System.out.println("Origem: " + leitor.getArestaOrigemCidade() + "\t Destino: " + leitor.getArestaDestinoCidade());

            listaGrafoTranspXDengue.get(semana).adicionaAresta(new Aresta(edge, 80, listaGrafoTranspXDengue.get(semana).getVertices().get(shortestPaths.get(i) - 1).getNumeroCidade(), listaGrafoTranspXDengue.get(semana).getVertices().get(shortestPaths.get(i+1) - 1).getNumeroCidade()));
            GraphConstants.setLineEnd(edge.getAttributes(), GraphConstants.ARROW_NONE);
            GraphConstants.setEndFill(edge.getAttributes(), true);
        }
    }

    public void pintaArestasTranspXDengue(int semana) {
        for (int w = 0; w < listaGrafoTranspXDengue.get(semana).getArestas().size(); w++) {
            //System.out.println("Origem = [" + listaGrafoRedeDengue.get(semana).getArestas().get(w).getOrigem() + "] e Destino = [" + listaGrafoRedeDengue.get(semana).getArestas().get(w).getDestino() + "]");
            grafoDengueTransp.get(semana).getGraphLayoutCache().insert(listaGrafoTranspXDengue.get(semana).getArestas().get(w).getCell());
        }
    }

    public void pintaVerticesTranspXDengue(int semana) {
        // Insert the cells via the cache, so they get selected
        for (int z = 0; z < listaGrafoTranspXDengue.get(semana).getVertices().size(); z++) {
            grafoDengueTransp.get(semana).getGraphLayoutCache().insert(listaGrafoTranspXDengue.get(semana).getVertices().get(z).getCell());
        }
    }

    public void desenhaGrafoDijkstra(int semana) {
        painelGrafo.removeAll();

        JInternalFrame frame = new JInternalFrame();
        pintaVerticesTranspXDengue(semana);
        pintaArestasTranspXDengue(semana);
        frame.getContentPane().add(new JScrollPane(grafoDengueTransp.get(semana)));
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension d = tk.getScreenSize();
        int altura = d.height;
        int largura = d.width;
        //frame.setSize(d.width, d.height - 100);
        //frame.setResizable(false);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        //frame.setVisible(true);
        painelGrafo.add(frame);
        painelGrafo.updateUI();

        frame.setSize(largura, altura - 50);
        frame.setVisible(true);
    }

    public void desenhaGrafoTransporte(){
        painelGrafo.removeAll();

        JInternalFrame frame = new JInternalFrame();
        frame.getContentPane().add(new JScrollPane(grafoTransporte));
        Toolkit tk=Toolkit.getDefaultToolkit();
        Dimension d=tk.getScreenSize();
        int altura = d.height;
        int largura = d.width;
        //frame.setSize(d.width, d.height - 100);
        //frame.setResizable(false);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        //frame.setVisible(true);
        painelGrafo.add(frame);
        painelGrafo.updateUI();

       frame.setSize(largura,altura - 50);
       frame.setVisible(true);
    }

    public void desenhaGrafoDengue(int semana) {
        painelGrafo.removeAll();

        JInternalFrame frame = new JInternalFrame();
        pintaVerticesDengue(semana);
        pintaArestasDengue(semana);
        frame.getContentPane().add(new JScrollPane(grafoDengue.get(semana)));
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension d = tk.getScreenSize();
        int altura = d.height;
        int largura = d.width;
        //frame.setSize(d.width, d.height - 100);
        //frame.setResizable(false);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        //frame.setVisible(true);
        painelGrafo.add(frame);
        painelGrafo.updateUI();

        frame.setSize(largura, altura - 50);
        frame.setVisible(true);
    }

    public void IniciaMatrizDeDistancia() {

        dist = new float[numeroCidades + 1][numeroCidades + 1];

        for (int i = 0; i <= numeroCidades; ++i) {
            for (int j = 0; j <= numeroCidades; ++j) {
                dist[i][j] = 0;
            }
        }
    }

    public void PreencheMatrizDeDistancia() {

        List<Aresta> listaAresta = grafoRedeTransporte.getArestas();
        for (int i = 0; i < numeroArestasRedeTransporte; i++) {
            dist[listaAresta.get(i).getOrigem()][listaAresta.get(i).getDestino()] = listaAresta.get(i).getPeso();
        }

    }

    private Grafo grafoRedeTransporte;
    private JGraph grafoTransporte = null;
    private ArrayList<JGraph> grafoDengue = null;
    private ArrayList<JGraph> grafoDengueTransp = null;
    private ArrayList<Grafo> listaGrafoRedeDengue = null;
    private ArrayList<Grafo> listaGrafoTranspXDengue = null;
    private JGraph grafoTranspDengue = null;
    private Integer numeroSemana;
    private int numeroCidades;
    private int numeroArestasRedeTransporte;
    private float dist[][];//matriz de distancias
    private float d[]; //guarda valor total do menor caminho
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButtonVisualizar;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JDialog jDialog1;
    private javax.swing.JDialog jDialog2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JDesktopPane painelGrafo;
    // End of variables declaration//GEN-END:variables

}
